package com.hushao.aimi.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * @description: 商品规格信息
 * @author: 胡少
 * @create: 2018-06-03 16:42
 **/
@ApiModel("商品规格信息")
@Entity
@Data
public class AimiProductSpec implements Serializable {
    @Id
    @GenericGenerator(name = "uuid",strategy = "uuid")
    @GeneratedValue(generator = "uuid")
    @Column(length = 32)
    private String id;

    /**
     * 商品id
     */
    @Column(length = 32,nullable = false)
    private String productId;

    /**
     * 规格名称
     */
    @NotNull(message = "规格名称不能为空")
    @Column(length = 64,nullable = false)
    private String name;

    /**
     * 商品规格价格
     */
    @NotNull(message = "价格不能为空")
    @Column(nullable = false)
    private BigDecimal price;

    /**
     *商品规格 图片
     */
    @Column(length = 512)
    private String image;

    /**
     * 商品规格库存
     */
    @NotNull(message = "库存不能为空")
    @Column(nullable = false)
    private Integer stock;

    @CreationTimestamp
    private Timestamp createTime;

    @UpdateTimestamp
    private Timestamp updateTime;

    @Column(length = 512)
    private String comment;

    public AimiProductSpec(String productId, @NotNull(message = "规格名称不能为空") String name, @NotNull(message = "价格不能为空") BigDecimal price, String image, @NotNull(message = "库存不能为空") Integer stock, Timestamp createTime, Timestamp updateTime, String comment) {
        this.productId = productId;
        this.name = name;
        this.price = price;
        this.image = image;
        this.stock = stock;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.comment = comment;
    }
}

